﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ch05
{
    class Class2
    {
        static void Main(string[] args)
        {
            //定义并实例化数组
            double[] score = new double[3];

            for (int i = 0; i < score.Length; i++)
            {
                Console.Write("请输入第{0}个分数：", i + 1);
                score[i] = double.Parse(Console.ReadLine());
            }
            
            //定义变量保存总分数
            double sum = 0;

            foreach (double s in score)
            {
                //Console.Write(s + "\t");
                //累加到sum
                sum += s;
            }

            //常用的算法：求和、求平均、求最大值、求最小值、排序


            //显示总分数(求和)
            Console.WriteLine("\n总成绩：{0}", sum);
            //显示平均分
            Console.WriteLine("平均分：{0}", sum / score.Length);

            Console.WriteLine("\n");
        }
    }
}
